<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/user-profile.css') ?>
<?php
$action = My_Utils::getController()->getRequest()->getActionName();
if ($action == 'profile') {
    $action = 'user-offers';
}
?>
<div class="span12">
    <h3>Witaj <?= $this->user['email'] ?></h3>
</div>

<div class="user-profile">
    <div>
        <ul class="nav nav-tabs" id="userProfileTabs">
            <li class="<?= $action == 'user-offers' ? 'active' : '' ?>" id="user-offers"><a href="#user-offers">Twoje ogłoszenia</a></li>
            <li class="<?= $action == 'user-catalogs' ? 'active' : '' ?>" id="user-catalogs"><a href="#user-catalogs">Twoje firmy i instytucje</a></li>
            <li class="<?= $action == 'contact-data' ? 'active' : '' ?>" id="contact-data"><a href="#contact-data">Dane kontaktowe</a></li>
            <li class="<?= $action == 'change-password' ? 'active' : '' ?>" id="change-password"><a href="#change-password">Zmiana hasła</a></li>
        </ul>
    </div>
    <div class="tab-content" id="userProfileTabsResults">
        <div class="tab-pane active" id="change-password"><?= $this->render('user/' . $action . '.phtml') ?></div>
    </div>
</div>

<script>
    $(function () {
            
        $('.user-profile').on('click', '#userProfileTabs a', function(event){
            var tab = $('#userProfileTabs').find('.active');
            var tabId = tab.attr('id');
            var url = '/user/' + tabId;            
            window.location = url;
        });
            
        $('#userProfileTabs').on('click', 'a', function (e) {
            e.preventDefault();
            $(this).tab('show');
            //            $('.search form.form-search').submit();
        });
            
    });
</script>